This page last changed on Nov 07, 2007 by cholmes.

Building and Running GeoServer with Maven

. In this Quickstart you will:

  • Check out the GeoServer source code from the subversion repository.
  • Build GeoServer Modules
  • Setup a GeoServer Configuration
  • Run GeoServer with Jetty

Source Code

  1. Ensure you have Subversion properly setup. Instructions here
  2. Open up a terminal and execute the following command:
    [/dev]% svn checkout https://svn.codehaus.org/geoserver/trunk/geoserver

Compiling

Maven build commands are executed from the command line.

Change directory to the root of the geoserver source tree and execute the following command:

[/dev]% cd geoserver
[/dev/geoserver]% mvn compile

This command will first download dependencies into your local repository, then compile all modules A successful compilation should result in output similar to the following.

[GEOSDEV:INFO]
[GEOSDEV:INFO]
[GEOSDEV:INFO] ------------------------------------------------------------------------
[GEOSDEV:INFO] Reactor Summary:
[GEOSDEV:INFO] ------------------------------------------------------------------------
[GEOSDEV:INFO] GeoServer ............................................. SUCCESS [GEOSDEV:0.475s]
[GEOSDEV:INFO] GeoServer Main Module ................................. SUCCESS [GEOSDEV:18.484s]
[GEOSDEV:INFO] GeoServer Web Feature Service Module .................. SUCCESS [GEOSDEV:3.421s]
[GEOSDEV:INFO] GeoServer Configuration Deployment PlugIn ............. SUCCESS [GEOSDEV:3.853s]
[GEOSDEV:INFO] GeoServer Web Application Module ...................... SUCCESS [GEOSDEV:6.500s]
[GEOSDEV:INFO] ------------------------------------------------------------------------
[GEOSDEV:INFO] ------------------------------------------------------------------------
[GEOSDEV:INFO] BUILD SUCCESSFUL
[GEOSDEV:INFO] ------------------------------------------------------------------------
[GEOSDEV:INFO] Total time: 33 seconds
[GEOSDEV:INFO] Finished at: Sun May 21 20:19:07 GMT+01:00 2006
[GEOSDEV:INFO] Final Memory: 9M/28M
[GEOSDEV:INFO] ------------------------------------------------------------------------
Advice

If compilation fails proceed due to a missing dependency, execute the command again. Chances are there was a problem downloading the dependency from a remote problem. If the problem persists you have two options:

  1. Email the developer list
  2. Find the dependency manually and copy into your local repository.

Building

The term bulding refers to installing the geoserver modules into your local maven repository. The build workflow is identical to the compilation workflow.

From the root of the geoserver source tree:

[/dev/geoserver]% mvn install
Configuration

If you receive the following error while trying to build:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to execute: Executing Ant script: /config.build.xml [config]: Failed to execute.

Unable to locate configuration: /home/jdeolive/devel/geoserver/trunk/web/basic
...

It means that the configuration files have not been set up properly. See the section below titled "Building the Web Module".

Building the Web module

See here for the information about how GeoServer configurations work. When building the web module a particular configuration must be specified. A configuration is specified with two properties:

  • configId: The id or name of the configuration, examples include "minimal", "release", "citeWFS", "citeWMS", etc...
  • configDirectory: The directory which contains the configuration specified by configId.

By default the web module is built with the "minimal" configuration which located directly in the web module itself. This configuration is empty and not much to look at

Alternate configurations are located in the subversion repository .

Let's check out a configuration now:

[/dev/geoserver]% cd ..
[/dev/]% mkdir configuration
[/dev/]% cd configuration
[/dev/configuration]% svn checkout https://svn.codehaus.org/geoserver/trunk/configuration/release

Now we can go to the web module and ask it to use the configuration we just checked out.

[/dev/geoserver/web]mvn install -DconfigId=release -DconfigDirectory=../../configuration

Running the Server

Running with Jetty

Maven comes with built-in support for Jetty via plug-in.

To run GeoServer with Jetty:

  1. Build all modules
  2. Change directory to the root of the web module
  3. Execute the maven comand:
    [/dev/geoserver/web]% mvn jetty:run

Open up your browser

Congrats!

Offline Mode

To prevent maven from trying to download a new version of the Jetty plug-in you can run the above command in offline mode:

[/dev/geoserver/web]% mvn -o jetty:run
Alternate data_dir configuration

There is an alternative way to tell GeoServer to use the configuration. Instead of building with a data directory it points directly at the directory on run time. To do this you just do:

[/dev/geoserver/web]mvn install
[/dev/geoserver/web]mvn run -DGEOSERVER_DATA_DIR=/Users/cholmes/gs-dir

Where the gs-dir is the location of your data_dir. You can point that directly at the svn release configuration, or can copy a configuration to a stable location, where you can add lots of data without having it reset every time you do a mvn install.

For more information check out Maven Build Reference.

It seems that it won't connect to mortbay.org when trying to install.  Is this likely to be a temporary problem (the website just happens to be down) or has it been moved?

Posted by [email protected] at Aug 28, 2007 11:25
Document generated by Confluence on Jan 16, 2008 23:26